//
//  KINGBaseTableViewController.swift
//  肉荣微博
//
//  Created by king on 15/7/29.
//  Copyright © 2015年 king. All rights reserved.
//

import UIKit

class KINGBaseTableViewController: UITableViewController, KINGVisitorViewDelegate {

    var userLogin = KINGUserAccount.userAccount != nil
    //var userLogin = false
    override func loadView() {
        userLogin ? super.loadView() : loadVisitorView()
    }
    //MARK: - 懒加载视图
    lazy var visitorView:KINGVisitorView = {
        return KINGVisitorView()
    }()
    
    private func loadVisitorView() {
        view = visitorView
        visitorView.delegate = self
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", style: UIBarButtonItemStyle.Plain, target: self, action: "registerBtnDidClick")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", style: UIBarButtonItemStyle.Plain, target: self, action: "loginBtnDidClick")
    }
    
    func loginBtnDidClick() {
        let loginVc = UINavigationController(rootViewController: KINGOAuthViewController())
        presentViewController(loginVc, animated: true, completion: nil)
        print("登录")
    }
    
    func registerBtnDidClick() {
        print("注册")
    }

}
